<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:py="http://genshi.edgewall.org/"
      xmlns:xi="http://www.w3.org/2001/XInclude">

<xi:include href="master.html" />

<head>
    <meta content="text/html; charset=UTF-8" http-equiv="content-type" py:replace="''"/>
    <title py:if="user">Edit user | Yale Club Beijing</title>
    <title py:if="not user">Add user | Yale Club Beijing</title>
    <style type="text/css">
        #edituser{
            margin-top: 20px;
            border-spacing: 5px;
            width: 900px;
        }
        #edituser td{
            vertical-align: top;
            text-align: right;
        }
        input[type="text"], textarea{width:100%;}
        #userdesc{
            height: 300px;
        }
    </style>
    <link href="/static/javascript/datepicker/datepicker.css" rel="stylesheet" type="text/css" media="screen" />
    
<script type="text/javascript">
    //<![CDATA[
    window.addEvent('domready',function(){
        $('userform').addEvent('submit', function(){
            validate();
            return false;
        });
        $('userdiscard').addEvent('click', function(){
            document.location = "users";
        });
        new DatePicker('userdob');
    });
    function validate(){
        if (!$("username").value){
            alert("Name can not be empty.");
            return;
        }
        if (!$("useremail").value){
            alert("Email can not be empty.");
            return;
        }
        $('userform').submit();
    }
    //]]>
    </script>
    <script src="/static/javascript/datepicker.js" type="text/javascript"></script>
</head>
<body>
<h1 py:if="user">Edit user</h1>
<h1 py:if="not user">Add user</h1>
<form id="userform" method="post" action="adduser">
<table id="edituser">
    <tr>
    	<td><b>Name</b></td>
    	<td><input type="text" id="username" name="name" value="${user.name if user else None}"/></td>
    	<td><b>Email</b></td>
    	<td><input type="text" id="useremail" name="email" value="${user.email if user else None}"/></td>
    </tr>
    <tr>
    	<td><b>Phone</b></td>
    	<td><input type="text" id="userphone" name="phone" value="${user.phone if user else None}"/></td>
    	<td><b>Date of birth</b></td>
    	<td><input id="userdob" name="dob" type="text" class="date_picker" value="${user.dobstr if user else None}"/></td>
    </tr>
    <tr><td><b>Website</b></td><td colspan="3"><input type="text" id="userwebsite" name="website" value="${user.website if user else None}"/></td></tr>
    <tr><td><b>About myself</b></td><td colspan="3"><textarea class="tinymce" id="userdesc" name="desc">${user.desc if user else None}</textarea></td></tr>
    <tr><td></td><td><input type="submit" value="Save" /></td><td><input id="userdiscard" type="button" value="Discard" /></td><td></td></tr>
</table>
<input py:if="user" type="hidden" name="uid" value="${user.id}" />
</form>
</body>
</html>

